package com.xiaotu.server.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.xiaotu.common.util.SpringContextHolder;

@SuppressWarnings("serial")
public class InitServlet extends HttpServlet
{
	
	private static final Logger LOGGER = LoggerFactory
			.getLogger(InitServlet.class);
	
	@Override
	public void init() throws ServletException
	{
		try
		{
			ApplicationContext applicationContext = WebApplicationContextUtils
					.getRequiredWebApplicationContext(getServletContext());
			(new SpringContextHolder())
					.setApplicationContext(applicationContext);
		}
		catch (Exception e)
		{
			LOGGER.error("初始化Spring上下文出错  " + e);
		}
	}
	
}
